package com.hongyuan.sellfitness.ui.person.view_mode;

import android.app.Application;

import androidx.annotation.NonNull;
import com.hongyuan.mvvmhabitx.bus.event.SingleLiveEvent;
import com.hongyuan.sellfitness.base.Constants;
import com.hongyuan.sellfitness.base.CustomViewModel;
import com.hongyuan.sellfitness.data.MyRepository;
import com.hongyuan.sellfitness.ui.person.beans.CancelReservationBean;

import java.util.List;

public class CancelReservationViewModel extends CustomViewModel<MyRepository> {

    public CancelReservationViewModel(@NonNull Application application, MyRepository model) {
        super(application, model);
    }

    //封装一个界面发生改变的观察者
    public UIChangeObservable uc = new UIChangeObservable();
    public class UIChangeObservable {
        public SingleLiveEvent<List<CancelReservationBean.ListBean>> showReason = new SingleLiveEvent<>();
    }


    @Override
    protected void returnData(int code, Object dataBean) {
        super.returnData(code, dataBean);

        if(code == Constants.GET_CANCEL_RESON){
            List<CancelReservationBean.ListBean> mList = ((CancelReservationBean)dataBean).getList();
            uc.showReason.setValue(mList);
        }

        if(code == Constants.CANCEL_COURSE_PRIVITE_APPOINTMENT_NEW){
            finish();
        }

    }
}
